# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: fossdd <fossdd@pwned.life>
pkgname=aws-c-s3
pkgver=0.7.0
pkgrel=0
pkgdesc="AWS C99 library implementation for communicating with the S3 service"
url="https://github.com/awslabs/aws-c-s3"
# s390x: aws-c-common
arch="all !s390x"
license="Apache-2.0"
makedepends="
	aws-c-auth-dev
	aws-c-cal-dev
	aws-c-common-dev
	aws-c-compression-dev
	aws-c-http-dev
	aws-c-io-dev
	aws-c-sdkutils-dev
	aws-checksums-dev
	cmake
	curl-dev
	s2n-tls-dev
	samurai
	"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/awslabs/aws-c-s3/archive/refs/tags/v$pkgver.tar.gz"
options="!check"  # The unit tests require an AWS account with S3 buckets set up in a particular way.

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		$crossopts
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

dev() {
	default_dev
	amove usr/lib/aws-c-s3
}

sha512sums="
41b3d84726f828d52576f4a1b70f936d6e1f11ca832eb3d3faacac2c8fc667044c45189f1d68408639b87f5decd358890d8d91cf57fababde76b770d9b72200d  aws-c-s3-0.7.0.tar.gz
"
